import { deepClone } from '@/utils/index';

const liquid_fill = ({
  seriesData = [],
  seriesName = '',
  color = ['#294D99', '#156ACF', '#1598ED', '#45BDFF'],
  showLabel = true,
  labelSize = 24,
  cursor = 'auto',
}) => {
  const defaultConfig = {
    // tooltip: {
    //   confine: true,
    //   trigger: 'item',
    //   formatter: (params) => {
    //     let content =
    //       `<span">${params.seriesName || params.data.seriesName}</span><br />` +
    //       `${params.name}&nbsp;&nbsp;` +
    //       `<span style="font-weight:bold;">${params.data.value}</span><br />`;
    //     return content;
    //   },
    // },
    // grid: {
    //   top: '20%',
    //   left: '0.8%',
    //   right: '4%',
    //   bottom: '4%',
    //   containLabel: true,
    // },
    series: [
      {
        type: 'liquidFill',
        data: seriesData,
        color: color,
        cursor: cursor,
        radius: '100%',
        label: {
          show: showLabel,
          fontSize: labelSize,
          color: '#fff',
          insideColor: '#fff',
          formatter: (params) => {
            const value = Number((params.value * 100).toFixed(2));
            return `${value}%`;
          },
        },
        backgroundStyle: {
          color: 'transparent',
        },
        outline: {
          show: false,
        },
      },
    ],
  };

  const opt = deepClone(defaultConfig);
  return opt;
};

export default {
  liquid_fill,
};
